

package projectx.web.base.navi;

import java.io.Serializable;
import java.util.List;

import org.apache.log4j.Logger;

public abstract class Function implements Serializable {

    //--------------------------------------------------------------------------
    //   M E M B E R S
    //
    //--------------------------------------------------------------------------
    private String      _id = "";
    private String      _name;
    private String      _href;
    private String      _description;
    private int         _level;
    private Function    _parent;


    //--------------------------------------------------------------------------
    //   M E T H O D S
    //
    //--------------------------------------------------------------------------
  
    public void setId( String id ){ _id = id; }

   
    public void setName( String name ){ _name = name; }

   
    public void setHref( String href ){ _href = href; }

    
    public void setDescription( String description ){ _description = description; }

    
    protected void setLevel( int level ){ _level = level; }

   
    protected void setParent( Function parent ){ _parent = parent; }

   
    public String getId(){ return _id; }

    public String getName(){ return _name; }

    
    public String getHref(){ return _href; }

    public String getDescription(){ return _description; }

    public int getLevel(){ return _level; }

   
    public Function getParent(){ return _parent; }

  
    public void setParentList( List list ){

        if ( _parent != null ){
            list.add( _parent );
            _parent.setParentList( list );
        }
    }

   
    public void debug( Logger log ){

        log.debug( this );
    }

    public boolean equals( Object obj ){

        if ( obj instanceof Function ){

            Function    compare = (Function)obj;

            if ( this.getId().equalsIgnoreCase( compare.getId() ) ){
                return true;
            }
            else {
                return false;
            }
        }
        else {
            return false;
        }
    }

    public String toString(){

        return "Id["            + _id               + "]"
           + ", Name["          + _name             + "]"
           + ", Href["          + _href             + "]"
           + ", Description["   + _description      + "]"
           + ", Level["         + _level            + "]"
           + ", ParentId["      + ( ( _parent == null ) ? null : _parent.getId() ) + "]";
    }
}
